package com.firstsight.micro.homedo.conf;

import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class RedissonClientConfig {
    @Value("${spring.redis.host}")
    private String host;
    @Value("${spring.redis.port}")
    private String port;
    @Value("${spring.redis.database}")
    private Integer database;



    @Bean({"redissonClient"})
    public RedissonClient redissonSingle(){
        Config config = new Config();
        config.useSingleServer().setAddress("redis://"+host+":"+port);
        config.useSingleServer().setDatabase(database);
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }


}
